<HTML>
<HEAD>
<TITLE>JavaScript Source Code 3000:  Games:  Pokemon Invaders</TITLE>
<META HTTP-EQUIV="JavaScript Source Code 3000" CONTENT = "no-cache">
<META NAME="date" CONTENT="2000-09-09">
<META NAME="channel" CONTENT="Web Developer">
<META NAME="author" CONTENT="Sam Dodge (nancied@mac.com)">
<META NAME="section" CONTENT="Games">
<META NAME="description" CONTENT="Try your luck as a pokemon protecting the world against an invading enemy squad.">

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Sam Dodge (nancied@mac.com) -->
<!-- Web Site:  http://raichusscastle.hypermart.net -->




<!-- Begin

var timerID = null;
var patno = 1;
var cr = "\r\n";
var spcf1 = "";
var spcf2 = "";
var spcf3 = "";
var hitflag = 0;
var score = 0;
var selec = 0;
var rsmiss = "";
function array1(arn) {
this.length = arn;
for (var ar1 = 0; ar1 <= arn; ar1++) {
this[ar1] = 1; }
return this;
}
function init() {
blankx = new array1(63);
for (var makeblank = 0; makeblank < 63; makeblank++) {
blankx[makeblank] = "";
for (var addBlank = 0; addBlank < makeblank; addBlank++) {
blankx[makeblank] = blankx[makeblank] + " ";
   }
}
faker = new array1(24);
face = new array1(2);
face[1] = " (O_O) ";
face[2] = " (o_o) ";
mestotal = new array1(4);
interval1();
}
function restarter() {
inplay = 0;
blankno = 0;
totalblank = "";
lr = 1;
lowerlf = "";
downlf = "";
downno = 0;
missilex = 99;
missiley = 99;
mychrx = 1;
myblank = "";
mymove = 0;
selec = 1;
starter();
}
function starter() {
document.fmark.win.value=cr+cr+cr+cr+cr+cr+cr+cr+cr+cr
+"          Control the Pokemon and stop the enemy invasion!"+cr+cr+cr
+"                           Click SHOOT to begin!";
selec = 1;
}
function goleft() {
mymove = 0;
mychrx = mychrx - 1;
if (mychrx <= 0) { mychrx = 1; }
}
function goright() {
mymove = 0
mychrx = mychrx + 1;
if (mychrx >= 56) { mychrx = 55; }
}
function golmax() {
if (inplay == 1) { mymove = -1; }
}
function gormax() {
if (inplay == 1){ mymove = 1; }
}
function fire() {
if (inplay == 0){ if (selec == 1){ selec = 9; inplay = 1; init(); }
} else {
if (missiley == 99){ missiley = 18; missilex = mychrx + 3; }
   }
}
function gameover() {
score = 0;
for (var enerme = 1; enerme < 25; enerme++) {
if (faker[enerme] == 1){ score = score + 1; }
}
if (score == 0) {
document.fmark.win.value = cr+cr+cr+cr+cr+cr+cr+cr
+"                        Congratulations!"+cr+cr
+"                          YOU STOPPED THE ENEMY SQUAD!!";
} else {
document.fmark.win.value=cr+cr+cr+cr+cr+cr+cr+cr
+"                           GAME OVER"+cr+cr
+"                   "+score+" INVADERS GOT THROUGH";
}
inplay = 0;
}
function interval1() {
if (missiley != 99) { missiley = missiley - 1; }
if (missiley < 0){ missiley = 99; }
mychrx = mychrx + mymove;
if (mychrx <= 0){ mychrx = 1; }
if (mychrx >= 56){ mychrx = 55; }
blankno = blankno + lr;
totalblank = blankx[blankno];
if (blankno >= 20) { lr = -1; downno = downno + 1; blankno = 20; }
if (blankno <= 0) { lr = 1; downno = downno + 1; blankno = 0; }
if (downno >= 12) { gameover(); }
downlf = "";
for (var upperspc = 0; upperspc < downno; upperspc++) {
if (missiley == upperspc) {
downlf = downlf + blankx[missilex]+"|"+cr;
} else { downlf = downlf+cr; }
   }
if (inplay == 1) {
patno = patno + 1;
if (patno >= 3) { patno = 1; }
for (var addline = 1; addline < 5; addline++){
mestotal[addline] = totalblank;
rsmiss = "";
if (missiley == (downno+addline*2-2)) {
if (blankno <= missilex) {
hitflag = parseInt((missilex-blankno)/7, 10);
if (hitflag < 6) {
if ((missilex - blankno - (hitflag * 7)) >= 1) {
if ((missilex - blankno - (hitflag * 7)) <= 5) {
if (faker[(addline * 6) + hitflag - 5] == 1) {
faker[(addline * 6) + hitflag - 5] = 0;
missiley = 99;
         }
      }
   }
}else {
if (missilex > (blankno + 42)) {
rsmiss = blankx[missilex - blankno - 42]+"|";
      }
   }
} else {
mestotal[addline] = blankx[missilex]+"|";
if (missilex < (blankno-1)) {
mestotal[addline] = mestotal[addline]+blankx[blankno-1-missilex];
      }
   }
}
for (var addfaker = 1; addfaker < 7; addfaker++) {
if (faker[(addline*6)+addfaker-6] == 1) {
mestotal[addline] = mestotal[addline]+face[patno];
} else { mestotal[addline] = mestotal[addline]+"       "; }
}
mestotal[addline] = mestotal[addline]+rsmiss;
}
spcf1 = cr;
spcf2 = cr;
spcf3 = cr;
if (missiley == (downno+1)) { spcf1 = blankx[missilex]+"|"+cr; }
if (missiley == (downno+3)) { spcf2 = blankx[missilex]+"|"+cr; }
if (missiley == (downno+5)) { spcf3 = blankx[missilex]+"|"+cr; }
lowerlf = "";
for (var lowerspc = 0; lowerspc < (11-downno); lowerspc++) {
if (missiley == (downno+7+lowerspc)) {
lowerlf = lowerlf+blankx[missilex]+"|"+cr;
} else { lowerlf = lowerlf+cr; }
}
myblank = blankx[mychrx];
document.fmark.win.value = downlf+mestotal[1]+cr+spcf1
+mestotal[2]+cr+spcf2+mestotal[3]+cr+spcf3+mestotal[4]
+cr+lowerlf+myblank+""+cr+myblank+"(^_^)";
timerID = setTimeout("interval1()",250);
   }
}
//  End -->
</script>
</HEAD>

<BODY BGCOLOR=#ffffff vlink=#0000ff OnLoad="restarter()">

<BR>
<center>
<table width=600 cellpadding=0 cellspacing=10>
<tr>
<td width=468 align=center>

    
    
</td>
<td width=120 align=center>
    
</td>
</tr>
</table>
<BR>
<BR>
<basefont size=3>
<FONT SIZE="+2" FACE="Helvetica,Arial">
<A HREF="../index.htm" /" TARGET="_top"><FONT COLOR="#0000FF"><b>Home</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<A HREF="index.htm" /games/"><font color="#FF0000"><b>Games</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<FONT COLOR="#006666"><b>Pokemon Invaders</b></font></font>
<BR>
<BR>
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td><font FACE="helvetica,arial,geneva">
<br>
<br>
<!-- Description --><!--content_start-->
Try your luck as a pokemon protecting the world against an invading enemy squad.
<hr>
</td></tr>
</table>
<!-- Demonstration -->
<center>
<form method=post name=fmark>
<table border=1 cellspacing=0 cellpadding=0>
<tr><td align=center>
<textarea name=win rows=20 cols=63 wrap=virtual></textarea>
<pre><input type=button name=button value="&lt;- " onClick="golmax()"> <input type=button name=button value="SHOOT" onClick="fire()"> <input type=button name=button value=" -&gt;" onClick="gormax()"></pre>
<input type=button name=button value="  New Game  " onClick="restarter()">
</td>
</tr>
</table>
</form>
</center>

<P>
<P>
<a name="source">
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>JavaScript Source Code 3000:  Games:  Pokemon Invaders</b>
<p>Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s).  The script is yours!!!
<br><br></font></td></tr>
<tr><td BGCOLOR=yellow ALIGN=CENTER>
<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE="text" NAME="total" VALUE="Script Size:  5.64 KB" size=24>
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>

&lt;!-- THREE STEPS TO INSTALL POKEMON INVADERS:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the onLoad event handler into the BODY tag
  3.  Put the last coding into the BODY of your HTML document  --&gt;

&lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document  --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Original:  Sam Dodge (nancied@mac.com) --&gt;
&lt;!-- Web Site:  http://raichusscastle.hypermart.net --&gt;

&lt;! &gt;
&lt;! &gt;

&lt;!-- Begin

var timerID = null;
var patno = 1;
var cr = "\r\n";
var spcf1 = "";
var spcf2 = "";
var spcf3 = "";
var hitflag = 0;
var score = 0;
var selec = 0;
var rsmiss = "";
function array1(arn) {
this.length = arn;
for (var ar1 = 0; ar1 &lt;= arn; ar1++) {
this[ar1] = 1; }
return this;
}
function init() {
blankx = new array1(63);
for (var makeblank = 0; makeblank &lt; 63; makeblank++) {
blankx[makeblank] = "";
for (var addBlank = 0; addBlank &lt; makeblank; addBlank++) {
blankx[makeblank] = blankx[makeblank] + " ";
   }
}
faker = new array1(24);
face = new array1(2);
face[1] = " (O_O) ";
face[2] = " (o_o) ";
mestotal = new array1(4);
interval1();
}
function restarter() {
inplay = 0;
blankno = 0;
totalblank = "";
lr = 1;
lowerlf = "";
downlf = "";
downno = 0;
missilex = 99;
missiley = 99;
mychrx = 1;
myblank = "";
mymove = 0;
selec = 1;
starter();
}
function starter() {
document.fmark.win.value=cr+cr+cr+cr+cr+cr+cr+cr+cr+cr
+"          Control the Pokemon and stop the enemy invasion!"+cr+cr+cr
+"                           Click SHOOT to begin!";
selec = 1;
}
function goleft() {
mymove = 0;
mychrx = mychrx - 1;
if (mychrx &lt;= 0) { mychrx = 1; }
}
function goright() {
mymove = 0
mychrx = mychrx + 1;
if (mychrx &gt;= 56) { mychrx = 55; }
}
function golmax() {
if (inplay == 1) { mymove = -1; }
}
function gormax() {
if (inplay == 1){ mymove = 1; }
}
function fire() {
if (inplay == 0){ if (selec == 1){ selec = 9; inplay = 1; init(); }
} else {
if (missiley == 99){ missiley = 18; missilex = mychrx + 3; }
   }
}
function gameover() {
score = 0;
for (var enerme = 1; enerme &lt; 25; enerme++) {
if (faker[enerme] == 1){ score = score + 1; }
}
if (score == 0) {
document.fmark.win.value = cr+cr+cr+cr+cr+cr+cr+cr
+"                        Congratulations!"+cr+cr
+"                          YOU STOPPED THE ENEMY SQUAD!!";
} else {
document.fmark.win.value=cr+cr+cr+cr+cr+cr+cr+cr
+"                           GAME OVER"+cr+cr
+"                   "+score+" INVADERS GOT THROUGH";
}
inplay = 0;
}
function interval1() {
if (missiley != 99) { missiley = missiley - 1; }
if (missiley &lt; 0){ missiley = 99; }
mychrx = mychrx + mymove;
if (mychrx &lt;= 0){ mychrx = 1; }
if (mychrx &gt;= 56){ mychrx = 55; }
blankno = blankno + lr;
totalblank = blankx[blankno];
if (blankno &gt;= 20) { lr = -1; downno = downno + 1; blankno = 20; }
if (blankno &lt;= 0) { lr = 1; downno = downno + 1; blankno = 0; }
if (downno &gt;= 12) { gameover(); }
downlf = "";
for (var upperspc = 0; upperspc &lt; downno; upperspc++) {
if (missiley == upperspc) {
downlf = downlf + blankx[missilex]+"|"+cr;
} else { downlf = downlf+cr; }
   }
if (inplay == 1) {
patno = patno + 1;
if (patno &gt;= 3) { patno = 1; }
for (var addline = 1; addline &lt; 5; addline++){
mestotal[addline] = totalblank;
rsmiss = "";
if (missiley == (downno+addline*2-2)) {
if (blankno &lt;= missilex) {
hitflag = parseInt((missilex-blankno)/7, 10);
if (hitflag &lt; 6) {
if ((missilex - blankno - (hitflag * 7)) &gt;= 1) {
if ((missilex - blankno - (hitflag * 7)) &lt;= 5) {
if (faker[(addline * 6) + hitflag - 5] == 1) {
faker[(addline * 6) + hitflag - 5] = 0;
missiley = 99;
         }
      }
   }
}else {
if (missilex &gt; (blankno + 42)) {
rsmiss = blankx[missilex - blankno - 42]+"|";
      }
   }
} else {
mestotal[addline] = blankx[missilex]+"|";
if (missilex &lt; (blankno-1)) {
mestotal[addline] = mestotal[addline]+blankx[blankno-1-missilex];
      }
   }
}
for (var addfaker = 1; addfaker &lt; 7; addfaker++) {
if (faker[(addline*6)+addfaker-6] == 1) {
mestotal[addline] = mestotal[addline]+face[patno];
} else { mestotal[addline] = mestotal[addline]+"       "; }
}
mestotal[addline] = mestotal[addline]+rsmiss;
}
spcf1 = cr;
spcf2 = cr;
spcf3 = cr;
if (missiley == (downno+1)) { spcf1 = blankx[missilex]+"|"+cr; }
if (missiley == (downno+3)) { spcf2 = blankx[missilex]+"|"+cr; }
if (missiley == (downno+5)) { spcf3 = blankx[missilex]+"|"+cr; }
lowerlf = "";
for (var lowerspc = 0; lowerspc &lt; (11-downno); lowerspc++) {
if (missiley == (downno+7+lowerspc)) {
lowerlf = lowerlf+blankx[missilex]+"|"+cr;
} else { lowerlf = lowerlf+cr; }
}
myblank = blankx[mychrx];
document.fmark.win.value = downlf+mestotal[1]+cr+spcf1
+mestotal[2]+cr+spcf2+mestotal[3]+cr+spcf3+mestotal[4]
+cr+lowerlf+myblank+""+cr+myblank+"(^_^)";
timerID = setTimeout("interval1()",250);
   }
}
//  End --&gt;
&lt;/script&gt;
&lt;/HEAD&gt;

&lt;!-- STEP TWO: Insert the onLoad event handler into your BODY tag  --&gt;

&lt;BODY OnLoad="restarter()"&gt;

&lt;!-- STEP THREE: Copy this code into the BODY of your HTML document  --&gt;

&lt;center&gt;
&lt;form method=post name=fmark&gt;
&lt;table border=1 cellspacing=0 cellpadding=0&gt;
&lt;tr&gt;&lt;td align=center&gt;
&lt;textarea name=win rows=20 cols=63 wrap=virtual&gt;&lt;/textarea&gt;
&lt;pre&gt;&lt;input type=button name=button value="&lt;- " onClick="golmax()"&gt; &lt;input type=button name=button value="SHOOT" onClick="fire()"&gt; &lt;input type=button name=button value=" -&gt;" onClick="gormax()"&gt;&lt;/pre&gt;
&lt;input type=button name=button value="  New Game  " onClick="restarter()"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/center&gt;


 

&lt;!-- Script Size:  5.64 KB --&gt;</textarea><br><font FACE="helvetica,arial,geneva"></font></td></tr>

</table>
</form>
</FONT>
</CENTER>


</center>
</body></html>